<template>
  <div>
    <!-- pending 页面 -->
    <template v-if="pageName === 'PENDING'">
      <div>
        <el-button
          v-preventReClick
          type="text"
          @click.stop="orderConfirm('one', scope.row.order.id)"
        >Confirm</el-button>
      </div>
    </template>

    <div v-if="pageName === 'CONFIRM'">
      <el-button
        type="text"
        @click.stop="showChannelDialog('one', scope.row.order.id, 'submit')"
      >Fulfill By Online</el-button>
    </div>

    <template v-if="pageName === 'PROCESSING'">
      <div>
        <el-button
          v-if="scope.row.order.isUrgent === 0"
          v-preventReClick
          type="text"
          @click.stop="orderUrgent('one', scope.row.order.id)"
        >Urgent</el-button>
      </div>
      <div>
        <el-button
          v-if="scope.row.order.isUrgent === 1"
          v-preventReClick
          type="text"
          @click.stop="orderUnurgent(scope.row.order.id)"
        >Cancel Urgent</el-button>
      </div>
    </template>

    <template v-if="pageName === 'SHIPPED'">
      <div>
        <el-button
          type="text"
          @click.stop="handletrack(scope.row.order.waybill)"
        >Track</el-button>
      </div>
      <div>
        <el-button type="text" @click.stop="">Reship</el-button>
      </div>
    </template>
    <template>
      <div>
        <el-button v-if="pageName === 'PENDING' || pageName === 'CONFIRM' || pageName === 'PROCESSING'" type="text" @click.stop="orderDet(scope.row.order.id)">detail</el-button>
      </div>
      <div>
        <el-button type="text" @click.stop="showNoteDialog('one', scope.row.order)">Note</el-button>
      </div>
    </template>
    <div v-if="pageName === 'TRASH'">
      <el-button
        type="text"
        @click.stop="orderDelete('one', scope.row.order.id)"
      >Delete</el-button>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    scope: {
      type: Object,
      required: true
    },
    pageName: {
      type: String,
      required: true
    },
    orderDet: {
      type: Function,
      required: true
    },
    showResendDialog: {
      type: Function,
      required: true
    },
    orderConfirm: {
      type: Function,
      required: true
    },
    orderSubmit: {
      type: Function,
      required: true
    },
    orderGoBack: {
      type: Function,
      required: true
    },
    showNoteDialog: {
      type: Function,
      required: true
    },
    orderUrgent: {
      type: Function,
      required: true
    },
    orderUnurgent: {
      type: Function,
      required: true
    },
    showChannelDialog: {
      type: Function,
      required: true
    },
    orderDelete: {
      type: Function,
      required: true
    }
  },
  methods: {
    // 单号追踪
    handletrack(waybill) {
      const url = 'https://t.17track.net/en#nums=' + waybill;
      window.open(url, '_blank');
    }
  }
};
</script>
<style lang="scss" scoped></style>
